/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package pl.lodz.p.ftims.ProjektZespolowy2.entities;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Łukasz Gadomski
 */
@Entity
@Table(name = "diagnozis")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Diagnosis.findAll", query = "SELECT d FROM Diagnosis d"),
    @NamedQuery(name = "Diagnosis.findByDiagnozisId", query = "SELECT d FROM Diagnosis d WHERE d.diagnozisId = :diagnozisId"),
    @NamedQuery(name = "Diagnosis.findByName", query = "SELECT d FROM Diagnosis d WHERE d.name = :name"),
    @NamedQuery(name = "Diagnosis.findByComment", query = "SELECT d FROM Diagnosis d WHERE d.comment = :comment"),
    @NamedQuery(name = "Diagnosis.findByActive", query = "SELECT d FROM Diagnosis d WHERE d.active = :active")})
public class Diagnosis implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "diagnozis_id")
    private Integer diagnozisId;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 50)
    @Column(name = "name")
    private String name;
    @Size(max = 255)
    @Column(name = "comment")
    private String comment;
    @Basic(optional = false)
    @NotNull
    @Column(name = "active")
    private boolean active;
    @JoinColumn(name = "appointment_id", referencedColumnName = "appointment_id")
    @ManyToOne(optional = false)
    private Appointment appointmentId;

    public Diagnosis() {
    }

    public Diagnosis(Integer diagnozisId) {
        this.diagnozisId = diagnozisId;
    }

    public Diagnosis(Integer diagnozisId, String name, boolean active) {
        this.diagnozisId = diagnozisId;
        this.name = name;
        this.active = active;
    }

    public Integer getDiagnozisId() {
        return diagnozisId;
    }

    public void setDiagnozisId(Integer diagnozisId) {
        this.diagnozisId = diagnozisId;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getComment() {
        return comment;
    }

    public void setComment(String comment) {
        this.comment = comment;
    }

    public boolean getActive() {
        return active;
    }

    public void setActive(boolean active) {
        this.active = active;
    }

    public Appointment getAppointmentId() {
        return appointmentId;
    }

    public void setAppointmentId(Appointment appointmentId) {
        this.appointmentId = appointmentId;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (diagnozisId != null ? diagnozisId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Diagnosis)) {
            return false;
        }
        Diagnosis other = (Diagnosis) object;
        if ((this.diagnozisId == null && other.diagnozisId != null) || (this.diagnozisId != null && !this.diagnozisId.equals(other.diagnozisId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "pl.lodz.p.ftims.ProjektZespolowy2.entities.Diagnozis[ diagnozisId=" + diagnozisId + " ]";
    }
    
}
